﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Zero.Dialogue
{
    public class UI_TalkTipPanel : MonoBehaviour
    {
        private Camera _mainCamera;

        public void Show(Vector3 worldPosition)
        {
            // 显示中不重复显示
            if (gameObject.activeSelf) return;

            // 获取主摄像机
            if (_mainCamera == null) _mainCamera = Camera.main;

            var screenPoint = _mainCamera.WorldToScreenPoint(worldPosition);
            transform.position = screenPoint;

            gameObject.SetActive(true);
        }

        public void Hide()
        {
            gameObject.SetActive(false);
        }
    }
}